package edu.pitt.dbmi.odie.gapp.gwt.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import edu.upmc.opi.caBIG.common.CaBIG_UUIdGenerator;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ODIE_User {
	
		@PrimaryKey
		@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
		private Key id;

		@Persistent
		private String odieId;

		@Persistent
		private String emailAddress;
		
		@Persistent
		private String nickname;
		
		public ODIE_User() {
			this.odieId = CaBIG_UUIdGenerator.getUUID() ;
		}

		public String toXml() {
			StringBuffer sb = new StringBuffer();
			if (id != null) {
		        sb.append("<user>") ;
				sb.append("<id>" + getOdieId() + "</id>");
				sb.append("<emailAddress>" + getEmailAddress() + "</emailAddress>");
				sb.append("<nickname>" + getNickname() + "</nickname>") ;
				sb.append("</user>") ;
			}
			return sb.toString();
		}
		
		public Key getId() {
			return id;
		}

		public String getOdieId() {
			return odieId;
		}

		public void setOdieId(String odieId) {
			this.odieId = odieId;
		}

		public String getEmailAddress() {
			return emailAddress;
		}

		public void setEmailAddress(String emailAddress) {
			this.emailAddress = emailAddress;
		}

		public String getNickname() {
			return nickname;
		}

		public void setNickname(String nickname) {
			this.nickname = nickname;
		}
}
